package session;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.*;

import entity.Item;
import entity.User;

/**
 * Session Bean implementation class HelloWorld
 */
@Stateful
public class CartBean implements Cart {
	private List<Item> items;
	private User owner;
    //protected SessionContext ctx;

    @PostConstruct
    public void initialize(User user) {
        items = new ArrayList<Item>();
        owner=user;        
    }
    public void addItem(Item item) {
        items.add(item);
    }
    public void removeItem(Item item) {
        items.remove(item);
    }
    public List<Item> getItems() {
        return items;
    }
    public void setOwner(User user){
    	this.owner=user;
    }
	public User getOwner() {
		return null;
	}
	@Remove
	public void remove(){
		items = new ArrayList<Item>();
		owner = new User();
	}
	public void setItems(List<Item> items) {
		this.items=items;		
	}
}